package fast.app;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import fast.main.service.BaseService;
import fast.main.util.Super;

public class Index extends Super{

	public String init(Map<String, Object> rmap){
		try{
			HttpServletRequest request=(HttpServletRequest) rmap.get("request");
			HttpServletResponse response=(HttpServletResponse) rmap.get("response");
			BaseService bs=(BaseService) rmap.get("bs");
			@SuppressWarnings("unchecked")
			HashMap<String, String> form= (HashMap<String, String>) rmap.get("form");
			
			//初始化         bs（数据库访问）、request（请求）,response（响应）,par（layui,table自定义参数）
			List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
			String sql=getSql("gncd_query");
			List<Map<String, Object>> resultlist = bs.query(sql);
			if(resultlist!=null&&resultlist.size()>0){
				for (int i = 0; i < resultlist.size(); i++) {
					Map<String, Object> map=resultlist.get(i);
					String gndm=String.valueOf(map.get("GNDM"));
					if(gndm!=null&&!gndm.trim().equals("")){
						sql=getSql("gncd_query_zcd",new Object[]{gndm});
						List<Map<String, Object>> gnlist = bs.query(sql);
						map.put("GNLIST", gnlist);
					}
					list.add(map);
				}
			}
			
			request.setAttribute("list", list);
			return "index";
		}catch(Exception e){
			e.printStackTrace();
			return "index";
		}
	}
}
